﻿using System;
using System.Linq;

    class ChangeTheValueOfTheBit
    {
        static void Main(string[] args)
        {
            int n = 5; 
            Console.WriteLine(Convert.ToString(n, 2));
            int v = 0;
            int p = 3;
            int mask = 1 << p;
            int nAndMask = n & mask;            
            int valueOfBit = nAndMask >> p; // find the value of the bit
            int setNullForBit = n & (~ mask);
            if (v == 1)
            {
                int changedBit = setNullForBit | mask;
                Console.WriteLine(changedBit);
            }
            if (v == 0)
            {
                int changedBit = setNullForBit & (~ mask);
                Console.WriteLine(changedBit);
            }
           
        }
    }

